package com.lxp.eduService.service.impl;

import com.lxp.eduService.client.VodClient;
import com.lxp.eduService.domain.EduVideo;
import com.lxp.eduService.mapper.EduVideoMapper;
import com.lxp.eduService.service.EduVideoService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 课程视频 服务实现类
 * </p>
 *
 * @author lxp
 * @since 2021-11-20
 */
@Service
public class EduVideoServiceImpl extends ServiceImpl<EduVideoMapper, EduVideo> implements EduVideoService {

    @Autowired
    private VodClient client; //注入服务
    //删除小节
    @Override
    public void removeVideo(String videoId) {
        //先删除视频
        //根据小节id,查找到阿里云的视频id
        EduVideo video = baseMapper.selectById(videoId);
        //根据阿里云视频id删除视频
        client.removeAlyVideo(video.getVideoSourceId());
        //最后删除小节
        baseMapper.deleteById(videoId);
    }
}
